// [域名]
export function validURL(url) {
    const reg = /^(?=^.{3,255}$)[a-zA-Z0-9][-a-zA-Z0-9]{0,62}(\.[a-zA-Z0-9][-a-zA-Z0-9]{0,62})+$/
    return reg.test(url)
}

// [网络地址]
export function validInternetURL(url) {
    const reg = /((([A-Za-z]{3,9}:(?:\/\/)?)(?:[\-;:&=\+\$,\w]+@)?[A-Za-z0-9\.\-]+|(?:www\.|[\-;:&=\+\$,\w]+@)[A-Za-z0-9\.\-]+)((?:\/[\+~%\/\.\w\-_]*)?\??(?:[\-\+=&;%@\.\w_]*)#?(?:[\.\!\/\\\w]*))?)/
    return reg.test(url)
}


// [IP]
export function validIP(ip) {
    const reg = /^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/
    return reg.test(ip)
}

// [字母数字]
export function validID(id) {
    const reg = /^[A-Za-z0-9]+$/
    return reg.test(id)
}

// [设备ID]
export function validDevice_ID(id) {
    //D0E000E-F0D0-0T01-0EC0-00E00
    const reg = /^[A-Z0-9]{7}-[A-Z0-9]{4}-[A-Z0-9]{4}-[A-Z0-9]{4}-[A-Z0-9]{5}$/
    return reg.test(id)
}

// [密碼]
export function vPassword(password="") {
    //const reg = /^(?![a-zA-z]+$)(?!\d+$)(?![!@#$%^&*]+$)[a-zA-Z\d!@#$&%^*_]{6,25}$/;
    const reg = /^(?![!@#$%^&*]+$)[a-zA-Z\d!@#$&%^*_]{6,25}$/;
    return reg.test(password)
}

// [用户名] 只能中文，英文，数字以及/ \\ * 空格
export function vUserName(password="") {
    const reg = /[^A-Za-z0-9\u4e00-\u9fa5\?\s]/g;
    return !reg.test(password)
}

// [邮箱]
export function vEmail(email="") {
    const reg = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
    return reg.test(email)
}

// [电话]
export function vPhone(phone) {
   const reg =  /^[0-9]{4,20}$/;
   return reg.test(phone)
}
